package com.export.xlsx.service.impl;


import com.export.xlsx.dao.CompanyDao;
import com.export.xlsx.dao.impl.CompanyDaoImpl;
import com.export.xlsx.domain.Company;
import com.export.xlsx.service.BusinessService;
import com.export.xlsx.utils.DaoFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.List;

/**
 * 业务处理实现类
 */
@Slf4j
public class BusinessServiceImpl implements BusinessService {

    private CompanyDao companyDao = DaoFactory.getInstance()
            .createDao("com.export.xlsx.dao.impl.CompanyDaoImpl", CompanyDaoImpl.class);

    @Override
    public Boolean addCompanyInfo(Company company) {
        Company c = companyDao.queryByName(company);

        if (null != c) {
            if (null == c.getC3() && null != company.getC3()) {
                companyDao.updC3(company);
            } else if (null == c.getC4() && null != company.getC4()) {
                companyDao.updC4(company);
            } else if (null == c.getC5() && null != company.getC5()) {
                companyDao.updC5(company);
            }
            return Boolean.TRUE;
        } else {
            return companyDao.addCompany(company);
        }
    }

    @Override
    public Company findCompanyInfo(Company company) {
        return companyDao.queryByName(company);
    }

    @Override
    public Boolean updateInfo(Company company, String phone, String person, String email, String addr, String taxAddr, String empSum, String techSum, String creditCode, String taxpayerCode, String regMon, String runPro, Integer comType, String establishmentDate, String recordDate, String regOrg) {
        return companyDao.updateInfo(company,phone,person,email,addr,taxAddr,empSum,techSum, creditCode, taxpayerCode, regMon, runPro, comType, establishmentDate, recordDate, regOrg);
    }

    @Override
    public Boolean insertInfo(Company company, String phone, String person, String email, String addr, String taxAddr, String empSum, String techSum, String creditCode, String taxpayerCode, String regMon, String runPro, Integer comType, String establishmentDate, String recordDate, String regOrg) {
        return companyDao.insertInfo(company,phone,person,email,addr, taxAddr, empSum,techSum, creditCode, taxpayerCode, regMon, runPro, comType, establishmentDate, recordDate, regOrg);
    }

    @Override
    public Boolean insertInfo1(Company company, String value, Integer typeNum, Integer year) {
        return companyDao.insertInfo1(company,value,typeNum, year);
    }

    @Override
    public Boolean updateInfo1(Company company, String phone, String person, String email, String addr, String empSum, String techSum, String managerSum) {
        return companyDao.updateInfo1(company, phone, person, email, addr, empSum, techSum, managerSum);
    }

    @Override
    public Boolean insertInfo2(Company company, String phone, String person, String email, String addr, String empSum, String techSum, String managerSum) {
        return companyDao.insertInfo2(company,phone,person,email,addr,empSum,techSum, managerSum);
    }

    @Override
    public Boolean updateBenke(Company company, String value, Integer typeNum, Integer year) {
        return companyDao.updateBenke(company,value,typeNum, year);
    }
}
